#include "Sym.h"
#include "Number.h"
namespace sympycpp {
Sym::Sym(const std::string & s) : Ex(SYM), title_(s) {
	sign(true);
}
std::string Sym::treeView(const int i) const {
	std::ostringstream stream;
	spaces(i, stream);
	char ch = sign() ? '+' : '-';
	stream << ">("<< ch << ")" << title_ << std::endl;
	return stream.str();
}
std::string Sym::title() const {
	return title_;
}
std::string Sym::str() const {
	if (sign()) {
		return title_;
	}
	else {
		return "-" + title_;  
	}
}
std::string Sym::unsigned_str() const {
		return title_;
}
Ex * Sym::copy() const {
	return new Sym(*this);
}
Ex * Sym::diff(const Sym & x) const {
	if (*this != x) {
		return new Number(0); 
	}
	if (sign()) {
		return new Number(1);
	}
	else {
		return new Number(-1);
	}
}
bool Sym::operator==(const Sym & x) const {
	return title_ == x.title_;
}
bool Sym::operator!=(const Sym & x) const {
	return title_ != x.title_;
}
}
